$package('YiYa.orderInfo');
YiYa.orderInfo = function(){
	var _box = null;
	var _this = {
		config:{
			event:{
				view:function(){
					var selected = _box.utils.getCheckedRows();
					if ( _box.utils.checkSelectOne(selected)){
						var record = selected[0];
						_box.handler.view();
						var url = '../employee/loadEmployeeList.do?serCompanyId='+record.serCompanyId;
						$('#cc4').combobox('reload',url);
					}
				}
			},
			dataGrid:{
				title:'维修单列表',
				url:'history_dataList.do',
				columns:[[
				          {field:'id',checkbox:true},
				          {field:'number',title:'编号',width:150},
				          {field:'repairType',title:'报修类型',width:60,
				        	  formatter:function(value,row,index){
				        		  var result = '';
				        		  if(row.repairType==0){
				        			  result = '新报修';
				        		  }else if(row.repairType==1){
				        			  result = '返修';
				        		  }
				        		  return result;
						  }},
						  {field:'company',title:'所属单位',width:120,
				        	  formatter:function(value,row,index){
				        		  return new Object(row["company"]).name;
						  }},
				          {field:'device_type',title:'设备类型',width:120,
				        	  formatter:function(value,row,index){
				        		  return new Object(row["deviceType"]).name;
						  }},
						  {field:'send_date',title:'派单日期',width:80,sortable:true,
				        	  formatter:function(value,row,index){
				        		  if(row["sendDate"]!=null){
				        		  return new Date(row["sendDate"].split(" ")[0].replace(/-/g,'/')).format("yyyy-MM-dd");
				        		  }
						      }
						  },
				          {field:'cpy_user_name',title:'申请人',width:80,
				        	  formatter:function(value,row,index){
				        		  return new Object(row["companyUserInfo"]).name;
						  }},
						  {field:'employee',title:'维修员',width:80,
				        	  formatter:function(value,row,index){
				        		  return new Object(row["employee"]).name;
						  }},
						  {field:'malfunctionDesc',title:'故障描述',width:120,
							  formatter:function(value,row,index){
								  if(value!=undefined){
									  if(value.length>10){
										  var str = value.substring(0,8);
										  return str.concat('......');	  
									  }
									  return value;
								  }
						  }},
						  {field:'userFeedback',title:'用户反馈',width:60,
				        	  formatter:function(value,row,index){
				        		  var result = '';
				        		  if(row.userFeedback==0){
				        			  result = '不满意';
				        		  }else if(row.userFeedback==1){
				        			  result = '满意';
				        		  }else{
				        			  result = '尚未反馈'
				        		  }
				        		  return result;
						  }},
						  {field:'orderStatus',title:'状态',width:60,
				        	  formatter:function(value,row,index){
				        		  var result = '';
				        		  if(row.orderStatus==0){
				        			  result = '已申请';
				        		  }else if(row.orderStatus==6){
				        			  result = '已接单';
				        		  }else if(row.orderStatus==12){
				        			  result = '已维修';
				        		  }else if(row.orderStatus==18){
				        			  result = '已反馈';
				        		  }else if(row.orderStatus==30){
				        			  result = '已结束';
				        		  }
				        		  return result;
						  }}
				          ]],
	          toolbar:[
	                   {id:'btnview',text:'查看',btnType:'view'}
	                   ]
			}
		},
		init:function(){
			$('#cc1').combobox({
			    onChange:function(newValue,oldValue){
			    	$("#cc2").combobox('clear');
			    }
			});
			_box = new YDataGrid(_this.config);
			_box.init();
		}
	}
	return _this;
}();

$(function(){
	YiYa.orderInfo.init();
});


